# -*- coding: utf-8 -*-
'''
求最大公约数
'''
def gcd(n,m):
  if m==0:
    return n
  return gcd(m, n%m)

arr = input().split()
a = int(arr[0])
b = int(arr[1])
print(gcd(a,b))